/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vadung.contragame2d;

import java.io.IOException;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 *
 * @author dung.voanh
 */
public class StateSplash extends State{

    private Image m_imgSplash;
   private String m_strHint;
    private int m_iOffsetHint;
    private Font m_fontLager;
    private Font m_fontSmaller;
     
    public StateSplash() { 
    }   
    
    public void Init() {
        //m_strHint = "Press any key go to Menu game.";
        m_strHint = GLOBAL.s_strSplashHint;
        m_iOffsetHint = 0;

        m_fontLager = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
        m_fontLager = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);

        m_imgSplash  = ResourceManager.GetInstance().GetImage(1);
                
    }

    public void Update() {
        if(m_iOffsetHint < m_strHint.length()){
            m_iOffsetHint++;
        }else{
            m_iOffsetHint = 0;
        }
        
        if(Midlet.s_canGame.GetKeyPressAction() != 0 || GLOBAL.IS_TOUCH){
            Midlet.s_canGame.SwitchState(DEFINE.STATE_MAINMENU);
        }
    }

    public void Render(Graphics g) {
        int height = Midlet.s_canGame.getHeight();
        int width = Midlet.s_canGame.getWidth();        
        int x = width/2;
        int y = height/2;
        g.drawImage(m_imgSplash, x, y, Graphics.HCENTER | Graphics.VCENTER);
        
        // Draw hint text
//        g.setFont(m_fontLager);
//        g.setColor(255, 255, 255); // Select white color
//        g.drawString("PLAY SELECT", x, y, Graphics.TOP|Graphics.RIGHT);
//        g.drawString("1 PLAYER", x, y + 20, Graphics.TOP|Graphics.RIGHT);
        
        // Draw hint text
        g.setFont(m_fontSmaller);
        g.setColor(255, 0, 0); // Select red color
        g.drawSubstring(m_strHint, 0, m_iOffsetHint, 5, height - 20, Graphics.TOP|Graphics.LEFT);
    }

    public void Exit() {
        m_imgSplash = null;
        m_fontLager = null;
    }
    
}
